<template>
  <div>
    <el-card class="box-card">
      <div class="BigDiv">
        <!--表格-->
        <el-table
            :data="tableData"
            height="600"
            border
            style="margin-top: 10px;width: 100%">
          <el-table-column prop="fileId" label="相关图片" width="180">
            <template slot-scope="scope">
              <el-image style="width: 110px; height: 110px" :src="scope.row.fileId"></el-image>
            </template>
          </el-table-column>
          <el-table-column
              prop="carportName"
              label="区域"
              width="180">
          </el-table-column>
          <el-table-column
              prop="carportCode"
              label="编号"
              width="180">
          </el-table-column>
          <el-table-column
              prop="carportAcreage"
              label="面积">
          </el-table-column>
          <el-table-column
              prop="carportFloor"
              label="楼层">
          </el-table-column>
          <el-table-column
              prop="carportType"
              label="车位类型">
            <template slot-scope="scope">
              {{scope.row.carportType ==0?"产权车位": scope.row.carportType == 1? "无产权车位":"是否产权车位"}}
            </template>
          </el-table-column>
          <el-table-column
              prop="carportState"
              label="车位状态">
            <template slot-scope="scope">
              {{scope.row.carportState ==0?"自用": scope.row.carportState == 1? "公用":"是否公用"}}
            </template>
          </el-table-column>
          <el-table-column
              fixed="right"
              label="操作">
            <template slot-scope="scope">
              <el-button type="primary" @click="passApprover(scope.row.id)">通过</el-button>
              <el-button type="warning" @click="rejectApprover(scope.row.id)">驳回</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!--表格-->
      </div>
    </el-card>
    <!--分页-->
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page=pageRquset.pageNum
        :page-sizes="[5, 10, 20, 30]"
        :page-size=pageRquset.pageSize
        layout="total, sizes, prev, pager, next, jumper"
        :total=total>
    </el-pagination>
    <!--分页-->
  </div>
</template>

<script>
export default {
  /*Data*/
  data() {
    return {
      currentPage2: 1,
      pageRquset: {
        pageSize: 5,
        pageNum: 1
      },
      total:0,
      tableData: []
    }
  },
  /*自动挂载*/
  mounted() {
    this.getApprover()
  },
  /*函数*/
  methods:{

    /*车行全查*/
    getApprover () {
      this.$axios.get('/memberLwh/carport/getApprover', {
        params: {
          pageSize: this.pageRquset.pageSize,
          pageNum: this.pageRquset.pageNum
        }
      }).then(res => {
        this.tableData = res.data.obj.content
        this.total = res.data.obj.total
      }).catch(error => {
        console.log(error)
      })
    },
    /*分页*/
    handleSizeChange (val) {
      this.pageRquset.pageSize = val
      this.getApprover()
    },
    handleCurrentChange (val) {
      this.pageRquset.pageNum = val
      this.getApprover()
    },
    /*驳回审批*/
    rejectApprover(id){
      debugger
      this.$confirm('是否驳回这条数据', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete('/memberLwh/carport/rejectApprover', {
          params: {
            id: id
          }
        }).then(res => {
          if (res.data.code === 200) {
            this.MyMessage('驳回成功', 'sussess')
            this.getApprover()
          } else {
            this.MyMessage('驳回失败', 'warning')
          }
        }).catch(res => {
          this.insertLog("车位驳回")
          this.MyMessage('驳回失败,请联系管理员', 'error')
        })
      }).catch(() => {
        this.MyMessage('已取消驳回', 'info')
      })
    },
    /*通过审批*/
    passApprover(id){
      debugger
      this.$confirm('是否通过审批', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete('/memberLwh/carport/passApprover', {
          params: {
            id: id
          }
        }).then(res => {
          if (res.data.code === 200) {
            this.MyMessage('审批成功', 'sussess')
            this.getApprover()
          } else {
            this.MyMessage('审批失败', 'warning')
          }
        }).catch(res => {
          this.insertLog("车位审批")
          this.MyMessage('审批失败,请联系管理员', 'error')
        })
      }).catch(() => {
        this.MyMessage('已取消审批', 'info')
      })
    },
    /*提示框*/
    MyMessage (msg, type) {
      this.$notify({
        showClose: true,
        message: msg,
        type: type
      })
    },
  }
}
</script>

<style>
*{
  margin: 0;
  padding: 0;
}
.ElInput{
  width: 200px;
}
.box-card{
  height: 820px;
  margin: 10px;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

</style>